<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>宏任务与微任务的执行顺序</title>
</head>
<body>
    <script>
        // 执行顺序优先级   同步 > 微任务 > 宏任务
        // 宏任务
        setTimeout(() => {
            console.log("setTime");
        },0)

        // 同步
        new Promise((resolve,reject) => {
            resolve("任务执行成功");
            console.log("hdms");
        }).then(
            // then中的回调函数是微任务
            value => {
                console.log("业务处理完成1");
            },
            resolve => {
                console.log("拒绝业务处理1");
            }
        ).then(
            value => {
                console.log("业务处理完成2");
            },
            resolve => {
                console.log("拒绝业务处理2");
            }
        )

        // 同步
        console.log("后盾人");
    </script>
</body>
</html>